Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix break rewrite rules #71

Merged
merged 2 commits into from Mar 28, 2016
Merged

Fix break rewrite rules #71

merged 2 commits into from Mar 28, 2016

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Mar 24, 2016

The rewrite rules of Data.ByteString.break are currently quite fragile (see GHC #11688 and #70) as they match on the (==) class method. Class methods call-sites at known types are subject to GHC-generated "Class Op" rewrite rules, which rewrite the call-site to a call directly to the appropriate instance's implementation. These rules fire rather early in simplification and therefore defeat bytestring's break rule.

The usual solution here is to give each particular instance's implementation of (==) a name which can be specifically matched (e.g. Int's (==) is defined in terms of GHC.Classes.eqInt). Unfortunately, such names were previously not available for Word8. This will be fixed in GHC 8.0 (as of D1980). This branch rewrites the break rules to match on these new functions, which should make them far more robust.

The second patch is merely a whitespace cleanup.

@bgamari bgamari changed the title Fix break rewrite ruies Fix break rewrite rules Mar 25, 2016
Previously these were matching on (==), which was rewritten by the class
op rule before the breakByte rule had an opportunity to fire (haskell#70).
Unfortunately fixing this requires that we change the Eq instances
provided by GHC. This has been done in GHC 8.0.1 (base-4.9.0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants